import heapq


class Solution:
    def kClosest(self, points: list, K: int) -> list:
        res = []
        for point in points:
            heapq.heappush(res, (-(point[0]**2 + point[1]**2), point))
            if len(res) > K:
                heapq.heappop(res)

        return [e[1] for e in res]
